package com.fjnldx.mes.mapper.monitor;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.fjnldx.mes.domain.domainReq.*;
import com.fjnldx.mes.domain.domainRes.XsRealTimeDataOfQuery;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

@Component
@Mapper
public interface MonitorMapper extends BaseMapper {
    /**
     * 车台实时数据-数据字典-级联1
     *
     * @param data
     * @return
     */
    @Select("SELECT DISTINCT gongxu,cs_type FROM canshu_table WHERE gongxu=#{gongxu}")
    List<DictionariesOneReturn> getRealTimeDataOfDictionariesOne(DictionariesOne data);

    /**
     * 车台实时数据-数据字典-级联2
     *
     * @param data
     * @return
     */
    @Select("SELECT DISTINCT gongxu,cs_type,cs,cs_name FROM canshu_table WHERE gongxu=#{gongxu} AND cs_type=#{cs_type}")
    List<DictionariesTwoReturn> getRealTimeDataOfDictionariesTwo(DictionariesTwo data);

    /**
     * 车台实时数据-细纱机-运行参数-设置参数-多段曲线
     *
     * @param data
     * @return
     */
    @Select("<script> " +
            "SELECT a.*,b.pz,b.dcg,b.gh,b.dqbc,b.dqbc_zcd FROM\n" +
            "(\n" +
            "SELECT b.* FROM\n" +
            "(SELECT devSn,MAX(id) id FROM xsmzl_table WHERE DATEDIFF(time,now())=0 AND " +
            "CASE \n" +
            "WHEN HOUR(now())&lt;12 \n" +
            "THEN\n" +
            "extract(hour from time) &lt;12\n" +
            "ELSE\n" +
            "extract(hour from time) &gt;=12\n" +
            "END " +
            "<if test='devSnArray != null and devSnArray.length >0'> " +
            "AND devSn in " +
            "<foreach collection='devSnArray' item='item' index='index' open='(' separator=',' close=')'> " +
            "#{item} " +
            "</foreach>" +
            "</if> " +
            "GROUP BY devSn) a\n" +
            "LEFT JOIN\n" +
            "(SELECT * FROM xsmzl_table) b\n" +
            "ON\n" +
            "a.id=b.id ORDER BY b.devSn+0 ASC\n" +
            ") a\n" +
            "LEFT JOIN\n" +
            "(SELECT  a.devSn,a.pz,a.dcg,a.gh,ROUND((b.a_zcd*a.dl*a.ds)/100000, 3) AS dqbc,b.a_zcd AS dqbc_zcd FROM\n" +
            "(\n" +
            "SELECT a.*,b.name AS dcg,b.gh FROM\n" +
            "(SELECT devSn,pz,gongxu,ds,dl,tc FROM mes_newscjh WHERE gongxu='细纱' AND DATEDIFF(time,now())=0 ) a\n" +
            "LEFT JOIN\n" +
            "(SELECT b.name,b.gh,a.devSn\n" +
            "FROM\n" +
            "(SELECT gh,devSn from scheduling where current_gongxu='细纱' AND now()&gt;=start_time AND now()&lt;=end_time ) a\n" +
            "LEFT JOIN\n" +
            "(SELECT DISTINCT gh,`name` FROM scheduling_personnel) b\n" +
            "ON a.gh=b.gh) b\n" +
            "ON\n" +
            "a.devSn=b.devSn\n" +
            ") a\n" +
            "LEFT JOIN\n" +
            "(SELECT devSn,MAX(dqcd),MAX(zcd+0.0)-MIN(zcd+0.0) AS a_zcd FROM xsmzl_table\n" +
            "WHERE DATEDIFF(time,date(now()))=0 AND " +
            "CASE \n" +
            "WHEN HOUR(now())&lt;12 \n" +
            "THEN\n" +
            "extract(hour from time) &lt;12\n" +
            "ELSE\n" +
            "extract(hour from time) &gt;=12\n" +
            "END " +
            "GROUP BY devSn) b  \n" +
            "ON\n" +
            "a.devSn=b.devSn) b\n" +
            "ON a.devSn=b.devSn GROUP BY devSn ORDER BY a.devSn+0 ASC" +
            "<if test='size!=-1 and page!=null'> limit ${page*size},#{size} </if>" +
            "</script>")
    List<Map<String,Object>> getXsRealTimeDataOfRun(XsRealTimeDataOfQuery data);

    @Select("<script> " +
            "SELECT count(*) FROM ( " +
            "SELECT a.*,b.pz,b.dcg,b.gh,b.dqbc,b.dqbc_zcd FROM\n" +
            "(\n" +
            "SELECT b.* FROM\n" +
            "(SELECT devSn,MAX(id) id FROM xsmzl_table WHERE DATEDIFF(time,now())=0 AND " +
            "CASE \n" +
            "WHEN HOUR(now())&lt;12 \n" +
            "THEN\n" +
            "extract(hour from time) &lt;12\n" +
            "ELSE\n" +
            "extract(hour from time) &gt;=12\n" +
            "END " +
            "<if test='devSnArray != null and devSnArray.length >0'> " +
            "AND devSn in " +
            "<foreach collection='devSnArray' item='item' index='index' open='(' separator=',' close=')'> " +
            "#{item} " +
            "</foreach>" +
            "</if> " +
            "GROUP BY devSn) a\n" +
            "LEFT JOIN\n" +
            "(SELECT * FROM xsmzl_table) b\n" +
            "ON\n" +
            "a.id=b.id ORDER BY b.devSn+0 ASC\n" +
            ") a\n" +
            "LEFT JOIN\n" +
            "(SELECT  a.devSn,a.pz,a.dcg,a.gh,ROUND((b.a_zcd*a.dl*a.ds)/100000, 3) AS dqbc,b.a_zcd AS dqbc_zcd FROM\n" +
            "(\n" +
            "SELECT a.*,b.name AS dcg,b.gh FROM\n" +
            "(SELECT devSn,pz,gongxu,ds,dl,tc FROM mes_newscjh WHERE gongxu='细纱' AND DATEDIFF(time,now())=0 ) a\n" +
            "LEFT JOIN\n" +
            "(SELECT b.name,b.gh,a.devSn\n" +
            "FROM\n" +
            "(SELECT gh,devSn from scheduling where current_gongxu='细纱' AND now()&gt;=start_time AND now()&lt;=end_time ) a\n" +
            "LEFT JOIN\n" +
            "(SELECT DISTINCT gh,`name` FROM scheduling_personnel) b\n" +
            "ON a.gh=b.gh) b\n" +
            "ON\n" +
            "a.devSn=b.devSn\n" +
            ") a\n" +
            "LEFT JOIN\n" +
            "(SELECT devSn,MAX(dqcd),MAX(zcd+0.0)-MIN(zcd+0.0) AS a_zcd FROM xsmzl_table\n" +
            "WHERE DATEDIFF(time,date(now()))=0 AND " +
            "CASE \n" +
            "WHEN HOUR(now())&lt;12 \n" +
            "THEN\n" +
            "extract(hour from time) &lt;12\n" +
            "ELSE\n" +
            "extract(hour from time) &gt;=12\n" +
            "END " +
            "GROUP BY devSn) b  \n" +
            "ON\n" +
            "a.devSn=b.devSn) b\n" +
            "ON a.devSn=b.devSn GROUP BY devSn ORDER BY a.devSn+0 ASC" +
            ") a " +
            "</script>")
    Integer getTotalXsRealTimeDataOfRun(XsRealTimeDataOfQuery data);

    /**
     * 车台实时数据-粗纱机-运行参数-设置参数-CCD
     *
     * @param data
     * @return
     */
    @Select("<script> " +
            "SELECT b.* FROM " +
            "(SELECT devSn,MAX(id) id FROM txcsoml_table WHERE DATEDIFF(time,now())=0 " +
            "<if test='devSnArray != null and devSnArray.length >0'> " +
            "AND devSn in " +
            "<foreach collection='devSnArray' item='item' index='index' open='(' separator=',' close=')'> " +
            "#{item} " +
            "</foreach>" +
            "</if> " +
            "GROUP BY devSn) a " +
            "LEFT JOIN " +
            "(SELECT * FROM txcsoml_table) b " +
            "ON " +
            "a.id=b.id ORDER BY b.devSn+0 ASC " +
            "<if test='size!=-1 and page!=null'> limit ${page*size},#{size} </if>" +
            "</script>")
    List<Map<String,Object>> getCsRealTimeDataOfRun(XsRealTimeDataOfQuery data);
    @Select("<script> " +
            "SELECT count(*) FROM ( " +
            "SELECT b.* FROM " +
            "(SELECT devSn,MAX(id) id FROM txcsoml_table WHERE DATEDIFF(time,now())=0 " +
            "<if test='devSnArray != null and devSnArray.length >0'> " +
            "AND devSn in " +
            "<foreach collection='devSnArray' item='item' index='index' open='(' separator=',' close=')'> " +
            "#{item} " +
            "</foreach>" +
            "</if> " +
            "GROUP BY devSn) a " +
            "LEFT JOIN " +
            "(SELECT * FROM txcsoml_table) b " +
            "ON " +
            "a.id=b.id ORDER BY b.devSn+0 ASC " +
            ") a " +
            "</script>")
    Integer getTotalCsRealTimeDataOfRun(XsRealTimeDataOfQuery data);
    /**
     * 车台实时数据-粗纱机-新设备
     *
     * @param data
     * @return
     */
    @Select("<script> " +
            "SELECT a.*,b.pz,ROUND((a.ljsc-b.m_ljsc),3) AS dqbcl,ROUND((a.ljsc-b.m_ljsc)*b.ds*b.dl,3) AS zlbcl FROM\n" +
            "(\n" +
            "SELECT b.* FROM \n" +
            "(SELECT devSn,MAX(id) id FROM txcsomlnew_table WHERE DATEDIFF(time,now())=0 \n" +
            "<if test='devSnArray != null and devSnArray.length >0'> " +
            "AND devSn in " +
            "<foreach collection='devSnArray' item='item' index='index' open='(' separator=',' close=')'> " +
            "#{item} " +
            "</foreach>" +
            "</if> " +
            "GROUP BY devSn) a \n" +
            "LEFT JOIN \n" +
            "(SELECT id, runTime,totalTime,time,stateCode,devSn,llsjzs,llxsd,dysjzs,ylsc,fsdc,ljsc,jllssj,ROUND((dysjzs / llxsd),3) AS csnd,ljsjxsd,ljsjwz,ROUND((fsdc-ylsc),3) AS sycd FROM txcsomlnew_table) b\n" +
            "ON \n" +
            "a.id=b.id ORDER BY b.devSn+0 ASC \n" +
            ") a\n" +
            "LEFT JOIN\n" +
            "(\n" +
            "SELECT a.m_ljsc,a.devSn,b.ds,b.dl,b.pz FROM\n" +
            "(\n" +
            "SELECT b.* FROM \n" +
            "(SELECT devSn,MAX(id) id FROM txcsomlnew_table WHERE DATEDIFF(time,now())=0 AND extract(hour from time)&lt;12\n" +
            "GROUP BY devSn) a \n" +
            "LEFT JOIN \n" +
            "(SELECT  ljsc AS m_ljsc,devSn,time ,id FROM txcsomlnew_table) b\n" +
            "ON \n" +
            "a.id=b.id ORDER BY b.devSn+0 ASC \n" +
            ") a LEFT JOIN\n" +
            "(SELECT pz,ds,dl,devSn FROM mes_newscjh WHERE DATEDIFF(time,now())=0 AND gongxu='粗纱' ) b ON a.devSn=b.devSn) b\n" +
            "ON a.devSn=b.devSn" +
            "<if test='size!=-1 and page!=null'> limit ${page*size},#{size} </if>" +
            "</script>")
    List<Map<String,Object>> getCsRealTimeDataOfRunNew(XsRealTimeDataOfQuery data);

    @Select("<script> " +
            "SELECT count(*) FROM ( " +
            "SELECT a.*,b.pz,ROUND((a.ljsc-b.m_ljsc),3) AS dqbcl,ROUND((a.ljsc-b.m_ljsc)*b.ds*b.dl,3) AS zlbcl FROM\n" +
            "(\n" +
            "SELECT b.* FROM \n" +
            "(SELECT devSn,MAX(id) id FROM txcsomlnew_table WHERE DATEDIFF(time,now())=0 \n" +
            "<if test='devSnArray != null and devSnArray.length >0'> " +
            "AND devSn in " +
            "<foreach collection='devSnArray' item='item' index='index' open='(' separator=',' close=')'> " +
            "#{item} " +
            "</foreach>" +
            "</if> " +
            "GROUP BY devSn) a \n" +
            "LEFT JOIN \n" +
            "(SELECT id, runTime,totalTime,time,stateCode,devSn,llsjzs,llxsd,dysjzs,ylsc,fsdc,ljsc,jllssj,ROUND((dysjzs / llxsd),3) AS csnd,ljsjxsd,ljsjwz,ROUND((fsdc-ylsc),3) AS sycd FROM txcsomlnew_table) b\n" +
            "ON \n" +
            "a.id=b.id ORDER BY b.devSn+0 ASC \n" +
            ") a\n" +
            "LEFT JOIN\n" +
            "(\n" +
            "SELECT a.m_ljsc,a.devSn,b.ds,b.dl,b.pz FROM\n" +
            "(\n" +
            "SELECT b.* FROM \n" +
            "(SELECT devSn,MAX(id) id FROM txcsomlnew_table WHERE DATEDIFF(time,now())=0 AND extract(hour from time)&lt;12\n" +
            "GROUP BY devSn) a \n" +
            "LEFT JOIN \n" +
            "(SELECT  ljsc AS m_ljsc,devSn,time ,id FROM txcsomlnew_table) b\n" +
            "ON \n" +
            "a.id=b.id ORDER BY b.devSn+0 ASC \n" +
            ") a LEFT JOIN\n" +
            "(SELECT pz,ds,dl,devSn FROM mes_newscjh WHERE DATEDIFF(time,now())=0 AND gongxu='粗纱' ) b ON a.devSn=b.devSn) b\n" +
            "ON a.devSn=b.devSn" +
            ") a " +
            "</script>")
    Integer getTotalCsRealTimeDataOfRunNew(XsRealTimeDataOfQuery data);

    /**
     * 车台实时数据-并条机
     *
     * @param data
     * @return
     */
    @Select("<script> " +
            "SELECT b.* FROM " +
            "(SELECT devSn,MAX(id) id FROM bingtiao_table WHERE DATEDIFF(time,now())=0 " +
            "<if test='devSnArray != null and devSnArray.length >0'> " +
            "AND devSn in " +
            "<foreach collection='devSnArray' item='item' index='index' open='(' separator=',' close=')'> " +
            "#{item} " +
            "</foreach>" +
            "</if> " +
            "GROUP BY devSn) a " +
            "LEFT JOIN " +
            "(SELECT * FROM bingtiao_table) b " +
            "ON " +
            "a.id=b.id ORDER BY b.devSn+0 ASC " +
            "<if test='size!=-1 and page!=null'> limit ${page*size},#{size} </if>" +
            "</script>")
    List<Map<String,Object>> getBtRealTimeData(XsRealTimeDataOfQuery data);

    @Select("<script> " +
            "SELECT count(*) FROM ( " +
            "SELECT b.* FROM " +
            "(SELECT devSn,MAX(id) id FROM bingtiao_table WHERE DATEDIFF(time,now())=0 " +
            "<if test='devSnArray != null and devSnArray.length >0'> " +
            "AND devSn in " +
            "<foreach collection='devSnArray' item='item' index='index' open='(' separator=',' close=')'> " +
            "#{item} " +
            "</foreach>" +
            "</if> " +
            "GROUP BY devSn) a " +
            "LEFT JOIN " +
            "(SELECT * FROM bingtiao_table) b " +
            "ON " +
            "a.id=b.id ORDER BY b.devSn+0 ASC " +
            ") a " +
            "</script>")
    Integer getTotalBtRealTimeData(XsRealTimeDataOfQuery data);

    /**
     * 车台实时数据-多仓
     *
     * @param data
     * @return
     */
    @Select("<script> " +
            "SELECT b.* FROM " +
            "(SELECT devSn,MAX(id) id FROM duocan_table WHERE DATEDIFF(time,now())=0 " +
            "<if test='devSnArray != null and devSnArray.length >0'> " +
            "AND devSn in " +
            "<foreach collection='devSnArray' item='item' index='index' open='(' separator=',' close=')'> " +
            "#{item} " +
            "</foreach>" +
            "</if> " +
            "GROUP BY devSn) a " +
            "LEFT JOIN " +
            "(SELECT * FROM duocan_table) b " +
            "ON " +
            "a.id=b.id ORDER BY b.devSn+0 ASC " +
            "<if test='size!=-1 and page!=null'> limit ${page*size},#{size} </if>" +
            "</script>")
    List<Map<String,Object>> getDcRealTimeData(XsRealTimeDataOfQuery data);

    @Select("<script> " +
            "SELECT count(*) FROM ( " +
            "SELECT b.* FROM " +
            "(SELECT devSn,MAX(id) id FROM duocan_table WHERE DATEDIFF(time,now())=0 " +
            "<if test='devSnArray != null and devSnArray.length >0'> " +
            "AND devSn in " +
            "<foreach collection='devSnArray' item='item' index='index' open='(' separator=',' close=')'> " +
            "#{item} " +
            "</foreach>" +
            "</if> " +
            "GROUP BY devSn) a " +
            "LEFT JOIN " +
            "(SELECT * FROM duocan_table) b " +
            "ON " +
            "a.id=b.id ORDER BY b.devSn+0 ASC " +
            ") a " +
            "</script>")
    Integer getTotalDcRealTimeData(XsRealTimeDataOfQuery data);

    /**
     * 车台实时数据-梳棉
     *
     * @param data
     * @return
     */
    @Select("<script> " +
            "SELECT b.* FROM " +
            "(SELECT devSn,MAX(id) id FROM shumianji_table WHERE DATEDIFF(time,now())=0 " +
            "<if test='devSnArray != null and devSnArray.length >0'> " +
            "AND devSn in " +
            "<foreach collection='devSnArray' item='item' index='index' open='(' separator=',' close=')'> " +
            "#{item} " +
            "</foreach>" +
            "</if> " +
            "GROUP BY devSn) a " +
            "LEFT JOIN " +
            "(SELECT * FROM shumianji_table) b " +
            "ON " +
            "a.id=b.id ORDER BY b.devSn+0 ASC " +
            "<if test='size!=-1 and page!=null'> limit ${page*size},#{size} </if>" +
            "</script>")
    List<Map<String,Object>> getSmRealTimeData(XsRealTimeDataOfQuery data);

    @Select("<script> " +
            "SELECT count(*) FROM ( " +
            "SELECT b.* FROM " +
            "(SELECT devSn,MAX(id) id FROM shumianji_table WHERE DATEDIFF(time,now())=0 " +
            "<if test='devSnArray != null and devSnArray.length >0'> " +
            "AND devSn in " +
            "<foreach collection='devSnArray' item='item' index='index' open='(' separator=',' close=')'> " +
            "#{item} " +
            "</foreach>" +
            "</if> " +
            "GROUP BY devSn) a " +
            "LEFT JOIN " +
            "(SELECT * FROM shumianji_table) b " +
            "ON " +
            "a.id=b.id ORDER BY b.devSn+0 ASC " +
            ") a " +
            "</script>")
    Integer getTotalSmRealTimeData(XsRealTimeDataOfQuery data);

    /**
     * 车台实时数据-梳棉a
     *
     * @param data
     * @return
     */
    @Select("<script> " +
            "SELECT b.* FROM " +
            "(SELECT devSn,MAX(id) id FROM shumianjia_table WHERE DATEDIFF(time,now())=0 " +
            "<if test='devSnArray != null and devSnArray.length >0'> " +
            "AND devSn in " +
            "<foreach collection='devSnArray' item='item' index='index' open='(' separator=',' close=')'> " +
            "#{item} " +
            "</foreach>" +
            "</if> " +
            "GROUP BY devSn) a " +
            "LEFT JOIN " +
            "(SELECT * FROM shumianjia_table) b " +
            "ON " +
            "a.id=b.id ORDER BY b.devSn+0 ASC " +
            "<if test='size!=-1 and page!=null'> limit ${page*size},#{size} </if>" +
            "</script>")
    List<Map<String,Object>> getSmARealTimeData(XsRealTimeDataOfQuery data);

    @Select("<script> " +
            "SELECT count(*) FROM ( " +
            "SELECT b.* FROM " +
            "(SELECT devSn,MAX(id) id FROM shumianjia_table WHERE DATEDIFF(time,now())=0 " +
            "<if test='devSnArray != null and devSnArray.length >0'> " +
            "AND devSn in " +
            "<foreach collection='devSnArray' item='item' index='index' open='(' separator=',' close=')'> " +
            "#{item} " +
            "</foreach>" +
            "</if> " +
            "GROUP BY devSn) a " +
            "LEFT JOIN " +
            "(SELECT * FROM shumianjia_table) b " +
            "ON " +
            "a.id=b.id ORDER BY b.devSn+0 ASC " +
            ") a " +
            "</script>")
    Integer getTotalSmARealTimeData(XsRealTimeDataOfQuery data);

    /**
     * 车台实时数据-开棉机-运行参数-设置参数
     *
     * @param data
     * @return
     */
    @Select("<script> " +
            "SELECT b.* FROM " +
            "(SELECT devSn,MAX(id) id FROM jingkaimianji_table WHERE DATEDIFF(time,now())=0 " +
            "<if test='devSnArray != null and devSnArray.length >0'> " +
            "AND devSn in " +
            "<foreach collection='devSnArray' item='item' index='index' open='(' separator=',' close=')'> " +
            "#{item} " +
            "</foreach>" +
            "</if> " +
            "GROUP BY devSn) a " +
            "LEFT JOIN " +
            "(SELECT * FROM jingkaimianji_table) b " +
            "ON " +
            "a.id=b.id ORDER BY b.devSn+0 ASC " +
            "<if test='size!=-1 and page!=null'> limit ${page*size},#{size} </if>" +
            "</script>")
    List<Map<String,Object>> getKmjRealTimeDataOfRun(XsRealTimeDataOfQuery data);

    @Select("<script> " +
            "SELECT count(*) FROM ( " +
            "SELECT b.* FROM " +
            "(SELECT devSn,MAX(id) id FROM jingkaimianji_table WHERE DATEDIFF(time,now())=0 " +
            "<if test='devSnArray != null and devSnArray.length >0'> " +
            "AND devSn in " +
            "<foreach collection='devSnArray' item='item' index='index' open='(' separator=',' close=')'> " +
            "#{item} " +
            "</foreach>" +
            "</if> " +
            "GROUP BY devSn) a " +
            "LEFT JOIN " +
            "(SELECT * FROM jingkaimianji_table) b " +
            "ON " +
            "a.id=b.id ORDER BY b.devSn+0 ASC " +
            ") a " +
            "</script>")
    Integer getTotalKmjRealTimeDataOfRun(XsRealTimeDataOfQuery data);

    /**
     * 车台实时数据-抓棉机-运行参数-设置参数-区数据
     *
     * @param data
     * @return
     */
    @Select("<script> " +
            "SELECT b.* FROM " +
            "(SELECT devSn,MAX(id) id FROM zmj_table WHERE DATEDIFF(time,now())=0 " +
            "<if test='devSnArray != null and devSnArray.length >0'> " +
            "AND devSn in " +
            "<foreach collection='devSnArray' item='item' index='index' open='(' separator=',' close=')'> " +
            "#{item} " +
            "</foreach>" +
            "</if> " +
            "GROUP BY devSn) a " +
            "LEFT JOIN " +
            "(SELECT * FROM zmj_table) b " +
            "ON " +
            "a.id=b.id ORDER BY b.devSn+0 ASC " +
            "<if test='size!=-1 and page!=null'> limit ${page*size},#{size} </if>" +
            "</script>")
    List<Map<String,Object>> getZmjRealTimeDataOfRun(XsRealTimeDataOfQuery data);

    @Select("<script> " +
            "SELECT count(*) FROM ( " +
            "SELECT b.* FROM " +
            "(SELECT devSn,MAX(id) id FROM zmj_table WHERE DATEDIFF(time,now())=0 " +
            "<if test='devSnArray != null and devSnArray.length >0'> " +
            "AND devSn in " +
            "<foreach collection='devSnArray' item='item' index='index' open='(' separator=',' close=')'> " +
            "#{item} " +
            "</foreach>" +
            "</if> " +
            "GROUP BY devSn) a " +
            "LEFT JOIN " +
            "(SELECT * FROM zmj_table) b " +
            "ON " +
            "a.id=b.id ORDER BY b.devSn+0 ASC " +
            ") a " +
            "</script>")
    Integer getTotalZmjRealTimeDataOfRun(XsRealTimeDataOfQuery data);

    /**
     * 车台实时数据-络筒-组数据
     *
     * @param data
     * @return
     */
    @Select("<script> " +
            "SELECT b.* FROM " +
            "(SELECT devSn,MAX(id) id FROM spero_table WHERE DATEDIFF(time,now())=0 " +
            "<if test='devSnArray != null and devSnArray.length >0'> " +
            "AND devSn in " +
            "<foreach collection='devSnArray' item='item' index='index' open='(' separator=',' close=')'> " +
            "#{item} " +
            "</foreach>" +
            "</if> " +
            "GROUP BY devSn) a " +
            "LEFT JOIN " +
            "(SELECT * FROM spero_table) b " +
            "ON " +
            "a.id=b.id ORDER BY b.devSn+0 ASC " +
            "<if test='size!=-1 and page!=null'> limit ${page*size},#{size} </if>" +
            "</script>")
    List<Map<String,Object>> getLtRealTimeDataOfGroup(XsRealTimeDataOfQuery data);

    @Select("<script> " +
            "SELECT count(*) FROM ( " +
            "SELECT b.* FROM " +
            "(SELECT devSn,MAX(id) id FROM spero_table WHERE DATEDIFF(time,now())=0 " +
            "<if test='devSnArray != null and devSnArray.length >0'> " +
            "AND devSn in " +
            "<foreach collection='devSnArray' item='item' index='index' open='(' separator=',' close=')'> " +
            "#{item} " +
            "</foreach>" +
            "</if> " +
            "GROUP BY devSn) a " +
            "LEFT JOIN " +
            "(SELECT * FROM spero_table) b " +
            "ON " +
            "a.id=b.id ORDER BY b.devSn+0 ASC " +
            ") a " +
            "</script>")
    Integer getTotalLtRealTimeDataOfGroup(XsRealTimeDataOfQuery data);

    /**
     * 参数修改记录
     * @return
     */
    IPage<List<Map<String, Object>>> parameterModificationRecord(ParameterModificationRecord parameterModificationRecord);

    /**
     * 映射关系-表名
     * @return
     */
    @Select("SELECT mapping_table FROM system_mapping_equipment WHERE gongxu=#{gongxu} AND equipment=#{equipment}")
    String mappingRelationTable(String gongxu,String equipment);

    /**
     * 映射关系-设备号
     * @return
     */
    @Select("SELECT gongxu,equipment FROM system_mapping_equipment WHERE gongxu=#{gongxu}")
    List<Map<String,Object>> mappingRelationEquipment(String gongxu);

    /**
     * 映射关系-历史表前缀
     * @return
     */
    @Select("SELECT history_table FROM system_mapping_equipment WHERE gongxu=#{gongxu} AND equipment=#{equipment}")
    String historyTablePrefix(String gongxu,String equipment);
}
